import request from '@/utils/request'
import { AxiosPromise } from 'axios'
import { TopupBo, TopupQueryBo } from '@/api/business/topup/types'

export enum Api {
  list = '/topup/list',
  remove = '/topup/remove',
  batchRemove = '/topup/batchRemove',
  add = '/topup/add',
  edit = '/topup/edit',
  detail = '/topup/detail',
  export = '/topup/export',
}

// 获取列表
export const list = (data): AxiosPromise<any> => {
  return request({
    url: Api.list,
    method: 'post',
    data,
  })
}

// 删除
export const remove = (data: string) => {
  return request({
    url: Api.remove,
    method: 'post',
    data,
  })
}
// 批量删除
export const batchRemove = (data: (string | number)[]) => {
  return request({
    url: Api.batchRemove,
    method: 'post',
    data,
  })
}

// 编辑、保存
export const save = (data: TopupBo) => {
  return request({
    url: data.id ? Api.edit : Api.add,
    method: 'post',
    data,
  })
}

// 详情
export const detail = (data: TopupQueryBo) => {
  return request({
    url: Api.detail,
    method: 'post',
    data,
  })
}
